public class sameString {
    public static void main(String[] args) {
        String str1 = "abcwerthelloyuiodef";
        String str2 = "cvhellobnm";
        String[] str=samestring(str1,str2);
        for (int i=0;i<str.length;i++){
            if (str[i]==null){
                break;
            }
            System.out.println(str[i]);
        }
        String str3 = "华信职员";
        String str4 = "职员华信";
        String[] str0=samestring(str3,str4);
        for (int i=0;i<str.length;i++){
            if (str0[i]==null){
                break;
            }
            System.out.println(str0[i]);
        }
    }
    static String[] samestring(String str1,String str2){
        int min = str1.length()<str2.length()?str1.length():str2.length();
        String[] str=new String[min];
        int index=0;
        for (int i=min;i>0;i--){
            if (str[0]!=null){
                break;
            }
            for (int j=i;j<=str1.length();j++){
                for (int k=i;k<=str2.length();k++){
                    if (str1.substring(j-i,j).equals(str2.substring(k-i,k))){
                        str[index++]=str1.substring(j-i,j);
                    }
                }
            }
        }
        return str;
    }
}
